var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("Util"),
    i = t("body"),
    s = t("fightManager"),
    c = t("skill"),
    l = cc._decorator,
    u = l.ccclass,
    p =
        (l.property,
        (function (t) {
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                return (e.pugongs = []), (e.skills = []), e;
            }
            return (
                n(e, t),
                (e.prototype.get_ready_skill = function () {
                    for (var t = 0; t < this.skills.length; t++) {
                        var e = this.skills[t];
                        if (e.is_ready() && this.body.mp.value >= e.data.nengliang) return e;
                    }
                    if (this.is_pugong_ready()) return this.get_random_pugong();
                }),
                (e.prototype.get_skill = function (t) {
                    return this.skills[t];
                }),
                (e.prototype.onEnable = function () {
                    this.body = this.getComponent(i.default);
                    for (var t = this.body.data.pugong, e = 0; e < t.length; e++) {
                        var o = t[e],
                            n = new c.default(o, this.body, !0);
                        this.pugongs.push(n);
                    }
                    var r = this.body.data.skills;
                    for (e = 0; e < r.length; e++) {
                        var a = r[e],
                            s = new c.default(a, this.body);
                        this.skills.push(s);
                    }
                }),
                (e.prototype.update = function (t) {
                    (t *= s.default.inst.speed.value),
                        this.pugongs.forEach(function (e) {
                            return e.update(t);
                        }),
                        this.skills.forEach(function (e) {
                            return e.update(t);
                        });
                }),
                (e.prototype.is_pugong_ready = function () {
                    for (var t = this.pugongs, e = 0; e < t.length; e++) {
                        if (!t[e].is_ready()) return !1;
                    }
                    return !0;
                }),
                (e.prototype.get_random_pugong = function () {
                    var t = a.RandomInt(0, this.pugongs.length - 1);
                    return this.pugongs[t];
                }),
                (e = r([u], e))
            );
        })(cc.Component));
o.default = p;
